/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Aug 2, 2009 2:58:22 PM $
 *
 * Author: Eric Yang
 * Date  : Aug 2, 2009 2:58:22 PM
 *
 */
package com.gooex.web.action;

import java.util.Set;

import org.c4j.system.web.action.Protected;

import com.gooex.domain.organization.Authority;
import com.gooex.service.organization.AuthorityContext;
import com.gooex.service.organization.IAreaManager;
import com.gooex.service.organization.IAuthorityManager;
import com.gooex.service.organization.IGroupManager;
import com.gooex.service.organization.IRoleManager;


/**
 * @author Eric Yang
 * @version 1.0
 */
public class BaseProtectedAction extends BaseAction implements Protected {

	protected IAuthorityManager authorityManager;

	protected IRoleManager roleManager;

	protected IAreaManager areaManager;

	protected IGroupManager groupManager;

	public final boolean hasAuthority(String name) {
		Authority authority = authorityManager.getAuthorityByName(name);
		if (authority == null)
			return false;

		return getCurrentUser().getRole().hasAuthority(authority);
	}

	public final Set<Authority> getSystemAutorities() {
		return AuthorityContext.getSystemAuthorities();
	}

	public final void setAuthorityManager(IAuthorityManager authorityManager) {
		this.authorityManager = authorityManager;
	}

	public final void setRoleManager(IRoleManager roleManager) {
		this.roleManager = roleManager;
	}

	public final void setAreaManager(IAreaManager areaManager) {
		this.areaManager = areaManager;
	}

	public final void setGroupManager(IGroupManager groupManager) {
		this.groupManager = groupManager;
	}

}
